/*
*******************************************************************************
COPYRIGHT 2010 Atech-Automotive
Source File Name : uds_diag_fun.c
Group            : ATECH
Author           :
Date First Issued:
********************************Documentation**********************************
General Purpose - This file contains the function prototypes for the driver fun
-ctions and the Data Types.
********************************RevisionHistory********************************
_______________________________________________________________________________
Date : MM/DD/YY                       Release : V1.0
Date : 05/10/2010                service operation in appl layer

******************************************************************************/
#define UDS_DIAG_FUN_C

/* #include */
#include "system.h"
#include "uds_diag_fun.h"

#include "uds_can_trans.h"
#include "uds_diag_drv.h"
#include "uds_diag_interface.h"
#include "uds_diag_appl_cfg.h"
#include "uds_diag_appl.h"

#pragma CODE_SEG  OTHER_ROM


//#include "Diag.h"

/* #define */

/* typedef */


/* static constants */

/* static function prototypes */

/****************************************************************************/
/**
 * Function Name: UdsDiag_GetVbatVoltage
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2017/01/17, hui.liu create this function
 ****************************************************************************/
UINT8 UdsDiag_GetVbatVoltage(void)
{
	#if 0
    return hwa_getVbat();
	#endif
	return 0;
}

#ifdef MODE_10_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_DiagnosticSessionCtrlVoltageTooHigh
 * Description: check vBatD valtage too high
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_DiagnosticSessionCtrlVoltageTooHigh(void)
{
	#if 0
    if(hwa_getVbat() > c_u8_HighV_TH)
    {
        return TRUE;
    }
	#endif
    return FALSE;
}

/****************************************************************************/
/**
 * Function Name: UdsDiag_DiagnosticSessionCtrlVoltageTooLow
 * Description: check vBatD valtage too low
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_DiagnosticSessionCtrlVoltageTooLow(void)
{
	#if 0
    if(hwa_getVbat() < c_u8_lowV_TH)
    {
        return TRUE;
    }
	#endif
    return FALSE;
}

/****************************************************************************/
/**
 * Function Name: UdsDiag_DiagnosticSessionCtrlProgramCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_DiagnosticSessionCtrlProgramCondition(void)
{
	#if 0
    if(HWA_GetInput(SI_IGN_IN)
        && app_can0GetSpeed() >= 3
        )  
    {
        return FALSE;
    }
    if(app_can0GetEnginState())
    {
        return FALSE;
    }
	#endif
    
    return TRUE;
}
#endif  /* MODE_10_SUPPORTED */

#ifdef MODE_11_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_ResetEcuCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_ResetEcuCondition(void)
{
    return TRUE;
}
#endif  /* MODE_11_SUPPORTED */

#ifdef MODE_14_SUPPORTED


#endif  /* MODE_14_SUPPORTED */


#ifdef MODE_19_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_GetMaxNumberOfDTC
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/09/28, hui.liu create this function
 ****************************************************************************/
UINT16 UdsDiag_GetMaxNumberOfDTC(void)
{
	#if 1
    return getNumOfSupportedDTCs() ;
	#endif

    return 0;
}

#endif  /* MODE_19_SUPPORTED */


#ifdef MODE_27_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_SecurityAccessReadAccessCounter
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_SecurityAccessReadAccessCounter(UINT8* p_u8_data)
{
    UINT8 resp = FALSE;
    
	#if 0
	p_u8_data[0] = pE2Data->security_access[0];
	p_u8_data[1] = pE2Data->security_access[1];
	p_u8_data[2] = pE2Data->security_access[2];
	p_u8_data[3] = pE2Data->security_access[3];
    #endif
	
	p_u8_data[0] = 0;
	p_u8_data[1] = 0;
	p_u8_data[2] = 0;
	p_u8_data[3] = 0;
	
    resp = TRUE;

    return resp;
}

/****************************************************************************/
/**
 * Function Name: UdsDiag_SecurityAccessWriteAccessCounter
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
void UdsDiag_SecurityAccessWriteAccessCounter(UINT8* p_u8_data)
{
	(void)p_u8_data;
	#if 0
    hwa_e2WriteDataById(E2_ADDR_security_access, p_u8_data);
	#endif
}

/****************************************************************************/
/**
 * Function Name: UdsDiag_SecurityAccessClearAccessCounter
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/08/09, hui.liu create this function
 ****************************************************************************/
void UdsDiag_SecurityAccessClearAccessCounter(void)
{
	#if 0
    UINT32 temp = 0;
    hwa_e2WriteDataById(E2_ADDR_security_access, (UINT8*)&temp);
	#endif
}

#endif  /* MODE_27_SUPPORTED */


#ifdef MODE_28_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_CommunicationControlDisableRxTxCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_CommunicationControlDisableRxTxCondition(void)
{
    return TRUE;
}
#endif  /* MODE_28_SUPPORTED */


#ifdef MODE_2E_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_WriteDataCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/28, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_WriteDataCondition(void)
{
    return TRUE;
}
#endif  /* MODE_2E_SUPPORTED */


#ifdef MODE_2F_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_InputOutputControlCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/26, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_InputOutputControlCondition(void)
{
    return TRUE;
}
#endif  /* MODE_2F_SUPPORTED */

#ifdef MODE_31_SUPPORTED

/****************************************************************************/
/**
 * Function Name: UdsDiag_RoutineControlCondition
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2016/07/26, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_RoutineControlCondition(void)
{
    return TRUE;
}

/****************************************************************************/
/**
 * Function Name: UdsDiag_RoutineDidControlCondition
 * Description: response NRC11 when this fun return is false
 *
 * Param:   none
 * Return:  none
 * Author:  2017/03/22, hui.liu create this function
 ****************************************************************************/
BOOL UdsDiag_RoutineDidControlCondition(RoutineCtrl_Cmd_E cmd, ROUTINE_CTRL_ID_E index)
{
    BOOL b_resp = TRUE;
    if(cmd == START_ROUTINE)
    {
        switch(index)
        {
            default:
                b_resp = TRUE;
                break;
        }
    }
    else if(cmd == REQ_ROUTINE_RESULTS)
    {
        switch(index)
        {
            default:
                b_resp = TRUE;
                break;
        }
    }
    return b_resp;
}

#endif  /* MODE_31_SUPPORTED */

#pragma CODE_SEG  DEFAULT

/******************* end of uds_diag_fun.c ***************************/

